package com.wlcj.plugin;

import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.annotation.AnnotationIocLoader;

import com.jfinal.plugin.IPlugin;

public class NutzPlugin implements IPlugin {
	
	static Ioc ioc = null;
	
	private String[] packages;
	
	public NutzPlugin(String...packages) {
		this.packages = packages;
	}

	@Override
	public boolean start() {
		ioc = new NutIoc(new AnnotationIocLoader(packages));
		return true;
	}

	@Override
	public boolean stop() {
		return true;
	}
	
	public static <T> T getBean(Class<T> clazz) {
		return ioc.get(clazz);
	}

}
